package org.example.tree;

import java.util.HashSet;
import java.util.Set;

/**
 * @author liyishan
 * @date 2024/5/23 10:41
 * @apiNote
 */

public class Test00653FindTarget {

    Set<Integer> set = new HashSet<Integer>();

    public boolean findTarget(TreeNode root, int k) {
        if(root == null){
            return false;
        }
        if(set.contains(k - root.val)){
            return true;
        }
        set.add(root.val);
        return findTarget(root.left,k) || findTarget(root.right,k);
    }

}
